package com.lz.behavior.state;

/**
 * esd..
 *
 * @author Lizhong
 * @date 2019/9/26
 */
public class AllState {
    public  class ForenoonState extends State {
        @Override
        public void writeProgram(Work02 work) {
            if (work.getHour() < 12) {
                System.out.println("当前时间" + work.getHour() + "上午工作，精神百倍");
            } else {
                // 关键6b状态装换
                work.setState(new NoonState());
                work.writeProgram();
            }
        }
    }

    public class AfternoonState extends State {
        @Override
        public void writeProgram(Work02 work) {
            if (work.getHour() < 17) {
                System.out.println("当前时间" + work.getHour() + "下午状态还不错，继续努力");
            } else {
                work.setState(new EveningState());
                work.writeProgram();
            }
        }
    }

    public class NoonState extends State {
        @Override
        public void writeProgram(Work02 work) {
            if (work.getHour() < 13) {
                System.out.println("当前时间" + work.getHour() + "饿了，午饭，犯困，休息");
            } else {
                work.setState(new AfternoonState());
                work.writeProgram();
            }
        }
    }

    public class EveningState extends State {
        @Override
        public void writeProgram(Work02 work) {
            if (work.isFinish()) {
                work.setState(new RestState());
                work.writeProgram();
            } else {
                if (work.getHour() < 21) {
                    System.out.println("当前时间" + work.getHour() + "加班哦，好难受");
                } else {
                    work.setState(new SleepingState());
                    work.writeProgram();
                }
            }
        }
    }

    public class RestState extends State {
        @Override
        public void writeProgram(Work02 work) {
            System.out.println("当前时间" + work.getHour() + "下班回家了");
        }
    }

    public class SleepingState extends State {
        @Override
        public void writeProgram(Work02 work) {
            System.out.println("当前时间" + work.getHour() + "不行了，睡着了");
        }
    }
}
